<?php

class Model_Videoblock extends Model{

    protected static $_instance =  null;
	/**
     * @return Model_Videoblock
     */
	static public function getInstance(){
        if(is_null(self::$_instance))	
           self::$_instance = new self('videoblock');     
        return self::$_instance;   
    }
    /**
     * Get video resources for page
     * @param integer $pageId
     * @param boolean $onlyPublished - optional, default - true
     * @return array
     */
    /*public function getResources($pageId , $onlyPublished = true){
    
        $sql = $this->_db->select()->from($this->_dbPrefix . self::$_table)->where('`page_id`  IN (?)',array(0 , intval($pageId)));
        
        if($onlyPublished)
            $sql->where('`published` = 1');
        
        $data = $this->_db->fetchAll($sql);
        
        if(empty($data))
            return array();
            
        $data = Core::rekey('page_id', $data);
        
        $linkKey = 0;

        if(isset($data[$pageId]))
            $linkKey = $data[$pageId]['id'];
         
       $links = Links::getInstance()->getLinks('videoblock_to_resource', $linkKey);
       $resIds = Utils::fetchCol('block_id' , $links);
       
       $resData = Resourcemodel::getInstance()->getItems($resIds);
         
       if(empty($resData))
           return array();

       $resData = Utils::rekey('id', $resData);
       $result = array();
        foreach ($links as $k=>$v){
            if(isset($resData[$v['block_id']]))
                $result[] = $resData[$v['block_id']];
        }
       
        return $result;   
    }
    */
}
